/*
 * Driver.cpp
 *
 *  Created on: Feb 14, 2014
 *      Author: benjamin
 */
#include <stdio.h>
#include "CNeuralNet.h"
#include <fstream>
#define TRAINING_FILE "training.txt"
int main (int argc, char ** argv){
	using namespace std;
	printf("Character classifier test cases\n");

	uint32_t training_set_size = 0,no_inputs = 0,no_outputs = 0;
	//load training data from input file:
	double ** inp;
	double ** out;
	ifstream f(TRAINING_FILE);
	if (f.is_open()){
		f >> training_set_size;
		f >> no_inputs;
		f >> no_outputs;
		inp = new double*[training_set_size];
		out = new double*[training_set_size];
		for (uint32_t i = 0; i < training_set_size; ++i){
			inp[i] = new double[no_inputs];
			out[i] = new double[no_outputs];
		}
		for (uint32_t i = 0; i < training_set_size; ++i){
			for (uint32_t inp_s = 0; inp_s < no_inputs; ++inp_s){
				f >> inp[i][inp_s];
			}
			for (uint32_t out_s = 0; out_s < no_outputs; ++out_s){
				f >> out[i][out_s];
			}
		}
		f.close();
	} else return 1;
	CNeuralNet classifier(no_inputs,50,no_outputs,0.2);
	classifier.train((const double **)inp,(const double **)out,training_set_size);

	for (uint32_t i = 0; i < training_set_size; ++i){
		delete[] inp[i];
		delete[] out[i];
	}

	delete[] inp;
	delete[] out;
	printf("Application terminated normally");
}

